<template>
  <ul class="box" v-if="isOpen">
    <li v-if="isSc">

       <p>收藏</p>
    </li>
    <li v-if="isShare">
       <button open-type="share" data-name="pageShare" id="share" @click="onShareAppMessage">
      <img src="../../static/images/share1.png" alt="">
      <p>分享</p>
      </button>
    </li>
  </ul>
</template>

<script>
  export default{
    props:['isOpen','isSc','isShare'],
    data(){
      return {

      }
    },
    methods:{

    },
    onShareAppMessage () {

     let shareData= JSON.parse(wx.getStorageSync('shareData'))
     let Authorization= wx.getStorageSync('Authorization')
      let cartId=wx.getStorageSync('cartId')
      let userId= wx.getStorageSync('userId')
      let that = this
      return {
        title: `您好,我是${shareData.company}的${shareData.name},这是我的名片,请惠存!`, // 转发后 所显示的title
        path: `/pages/index/main?Authorization=${Authorization}&cartId=${cartId}&userId=${userId}`, // 相对的路径
        imageUrl: shareData.logo,
        success: (res) => { // 成功后要做的事情
          //console.log(res.shareTickets[0])
          // console.log

          wx.getShareInfo({
            shareTicket: res.shareTickets[0],
            success: (res) => {
              //console.log(res)
              //console.log(that.setData.isShow)
            },
            fail: function (res) { console.log(res) },
            complete: function (res) { console.log(res) }
          })
        },
        fail: function (res) {
          // 分享失败
          console.log('分享失败' + res)
        }
      }
    },
  }
</script>

<style scoped>
  .box{
    width: 74rpx;
    height: 240rpx;
    background-color: #fff;

    /* border: 1px solid rgb(61,176,243); */
    border-radius: 30rpx;
    position: fixed;
    top:50%;
    right: 5%;
    font-size: 22rpx;
    display: flex;
    justify-content: center;
    align-content: center;
    flex-wrap: wrap;
    text-align: center;
    transform :translateY(-135rpx);
  }
  .box>li{
    width: 100%;

  }
  #share{
    width: 100%;
    height: 100%;
    background-color: #fff;
    border:none;
    padding-left: 0;
    padding-right: 0;
    font-size: 24rpx;

  }
  #share:after{
    border:none;
  }
  .box>li:first-child{
    margin-bottom: 10rpx;
  }
  .box img{
    width: 40rpx;
    height: 40rpx;
  }
</style>
